import http from '@/http';
import { Paper, PaperListResponse, CreatePaperRequest} from '@/types/paper';

enum url {
  paper = '/api/paper/',
}

export const paperService = {
  // 获取试卷列表
  getPapers: (params?: { page?: number; page_size?: number }) => {
    return http.get<PaperListResponse>(url.paper, { params });
  },

  // 获取单个试卷
  getPaper: (id: number) => {
    return http.get<Paper>(url.paper + id);
  },

  // 创建试卷
  createPaper: (data: CreatePaperRequest) => {
    return http.post<Paper>(url.paper, data);
  },

  // 更新试卷
  updatePaper: (id: number, data: Partial<CreatePaperRequest>) => {
    return http.patch<Paper>(`${url.paper}${id}/`, data);
  },

  // 删除试卷
  deletePaper: (id: number) => {
    return http.delete<Paper>(`${url.paper}${id}/`);
  },
}; 